package Algorithm.ReviewCode;



public class LinkedListRecDelete {

    public static ListNode removeElements(ListNode head, int val) {

        if (head == null) {
            return null;
        }

        ListNode res = removeElements(head.next, val);
        if (head.val == val) {
            return res;
        }else {
            head.next = res;
        }
        return head;
    }


    public static void main(String[] args) {
        int[] a = new int[]{1,2,3,4,2,5};
        ListNode listNode = new ListNode(a);
        System.out.println(listNode);
        ListNode listNode1 = removeElements(listNode,1);
        System.out.println(listNode1);

    }


}
